package com.cwvs.services;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cwvs.dao.AppOrderDao;
import com.cwvs.utils.Pages;
import com.pingplusplus.model.Charge;

@Service
public class AppOrderService {
	@Resource
	private AppOrderDao appOrderDao;

	/**
	 * 主订单生成
	 * 
	 * @param m
	 * @return
	 */
	public Map<String, Object> createOrder(Map<String, Object> m) {
		return appOrderDao.createOrder(m);
	}

	/**
	 * 通过订单类型获取订单信息
	 */
	public Map<String, Object> getOrderTypeByCode(String code) {
		return appOrderDao.getOrderTypeByCode(code);
	}

	/**
	 * 外卖类型列表
	 */
	public List<Map<String, Object>> takeOutList() {
		return appOrderDao.takeOutList();
	}

	/**
	 * 通过外卖CODE获取外卖信息
	 */
	public Map<String, Object> getTakeOutByCode(String code) {
		return appOrderDao.getOrderTypeByCode(code);
	}

	/**
	 * 获取个人订单列表
	 */
	public List<Map<String, Object>> getOrderListByUser(String uid,
			String[] status, int cpage) {
		return appOrderDao.getOrderListByUser(uid, status, cpage);
	}

	/**
	 * 订单总数
	 */
	public int getOrderCountByStatus(String uid, String[] status) {
		return appOrderDao.getOrderCountByStatus(uid, status);
	}

	/**
	 * 订单列表
	 * 
	 * @return
	 */
	public Pages orderList(Map<String, Object> m, Pages page) {
		return appOrderDao.orderList(m, page);
	}

	/**
	 * 通过用户ID和订单ID获取订单详细信息
	 * 
	 * @param uid
	 * @param id
	 * @return
	 */
	public Map<String, Object> orderInfoById(String uid, String id) {
		return appOrderDao.orderInfoById(uid, id);
	}

	/**
	 * 通过订单ID获取订单信息
	 * 
	 * @param id
	 * @return
	 */
	public Map<String, Object> getOrderInfoById(String id) {
		return appOrderDao.getOrderInfoById(id);
	}

	/**
	 * 更新订单价格和状态
	 */
	public boolean updateOrderStatusPrice(String id, BigDecimal price,
			int status, String statusName) {
		return appOrderDao
				.updateOrderStatusPrice(id, price, status, statusName);
	}

	/**
	 * 获取订单类型
	 */
	public List<Map<String, Object>> getAllOrderType() {
		return appOrderDao.getAllOrderType();
	}
	/**
	 * 回写订单支付charge
	 */
	public void updateOrderCharge(String orderId,String chargeId){
		appOrderDao.updateOrderCharge(orderId, chargeId);
	}
	/**
	 * 通过订单号获取订单信息
	 * 
	 * @param id
	 * @return
	 */
	public Map<String, Object> getOrderInfoByOrderNo(String orderNo) {
		return appOrderDao.getOrderInfoByOrderNo(orderNo);
	}	/**
	 * 更新订单状态
	 * @param id
	 * @param status
	 * @param statusName
	 * @return
	 */
	public boolean updateStatus(String id,int status,String statusName){
		return appOrderDao.updateStatus(id, status, statusName);
	}
	/**
	 * 插入订单流水记录
	 */
	public boolean insAppPayLog(String id, Charge ch) {
		return appOrderDao.insAppPayLog(id, ch);
	}
	/**
	 * 插入支付回调日志
	 */
	public boolean insAppReturnPayLog(Charge ch) {
		return appOrderDao.insAppReturnPayLog(ch);
	}
	/**
	 * 获取车辆类型
	 */
	public List<Map<String,Object>> getCarType(){
		return appOrderDao.getCarType();
	}
	
}
